#ifndef MINECRAFTBLOCKINSTANCEING_H
#define MINECRAFTBLOCKINSTANCEING_H

#include <QObject>
#include <QQuick3DInstancing>
#include <QtQmlIntegration>
#include "minecraftblocklibrary.h"
#include "minecraftscenedata.h"

class MineCraftBlockInstancing:public QQuick3DInstancing
{
    Q_OBJECT
    QML_ELEMENT
public:
    MineCraftBlockInstancing();


    BlockMeta::BlockType type() const;
    void setType(const BlockMeta::BlockType &newType);

    MineCraftSceneData *scene() const;
    void setScene(MineCraftSceneData *newScene);

signals:
    void typeChanged();
    void sceneChanged();

private:
    QByteArray getInstanceBuffer(int *instanceCount) override;
    MineCraftSceneData* m_scene = nullptr;
    BlockMeta::BlockType m_type = BlockMeta::None;//指定实例化场景中的哪种方块
    bool m_dirty = false;
    QByteArray m_buffer;
    int m_instanceCount = 0;
    Q_PROPERTY(BlockMeta::BlockType type READ type WRITE setType NOTIFY typeChanged FINAL)
    Q_PROPERTY(MineCraftSceneData *scene READ scene WRITE setScene NOTIFY sceneChanged FINAL)
};

#endif
